****************************************************************************************************************
**																											  **
** This do file is part of the replication material for the following article: 								  **
**  "Voter mobilization in the echo chamber: Broadband internet and the rise of populism in Europe" 	      **
** 		Authors: Max Schaub, Davide Morisi			    													  **
** 		Journal: European Journal of Political Research														  **
**																											  **
** This file replicates the following  step of the analysis: 												  **
**																											  **
**		ANALYSIS DATA ITALY - PAPER AND APPENDIX														      **
**																											  **
****************************************************************************************************************

*Set working directory
cd "..."

ssc install fre

use "Replication files\italy_itanes_panel_recoded.dta", clear

** Set sample
global cntrls_it "age10 sex i.edu_cat3_rev employed dens011 slope1 i.centres i.area1 unempl_011 ratio65_011 edu_high_01"
sum age10 sex edu_cat3_rev employed dens011 slope1 centres area1 unempl_011 ratio65_011 edu_high_01
eststo tslsfull: ivregress 2sls voteM5S $cntrls_it (internetw4_1 = bband13_01), cluster(municip) first
gen sample = e(sample)
drop if sample!=1
sum voteM5S internetw4_1 internetw4_1 bband13_01 age10 sex edu_cat3_rev employed dens011 slope1 centres area1 unempl_011 ratio65_011 edu_high_01

** Control variables
*local cntrls_it age10 sex i.edu_cat3_rev employed dens011 slope1 i.centres i.area1 unempl_011 ratio65_011 edu_high_01
global cntrls_it "age10 sex i.edu_cat3_rev employed dens011 slope1 i.centres i.area1 unempl_011 ratio65_011 edu_high_01"


//// Main models
eststo clear

*** Simple regression (OLS)
regress voteM5S internetw4_1 i.centres i.area1, cluster(municip)
regress voteM5S internetw4_1 $cntrls_it, cluster(municip)

*** Reduced form
eststo rfnaive: regress voteM5S bband13_01 i.centres i.area1, cluster(municip)
eststo rffull: 	regress voteM5S bband13_01 $cntrls_it, cluster(municip)

*** 2SLS
eststo tslsnaive:	ivregress 2sls voteM5S i.centres i.area1 (internetw4_1 = bband13_01), cluster(municip) first
eststo tslsfull:	ivregress 2sls voteM5S $cntrls_it (internetw4_1 = bband13_01), cluster(municip) first
eststo tslsfirst:	regress internetw4_1 bband13_01 $cntrls_it, cluster(municip)


******************************
******************************
*TABLES AND FIGURES IN THE PAPER


*Figure 3: Conditional independence of the instrument (orthogonality)
gen sex1 = sex
label variable sex1 "Female"
fre employ
label define employ 1 "Employee" 2 "Public servant" 3 "Retired" 4 "Houseworker" 5 "Student" 6 "Unemployed" 7 "Other not working", replace
recode employ 7=6
eststo ortho: regress bband13_01 age10 sex1 i.employ i.edu_cat3_rev lrscale01 intpol dens011 slope1 i.centres i.area1 unempl_011 ratio65_011 edu_high_01
* Plot
coefplot ortho, ///
drop(_cons dens011 slope1 *centres *area1 unempl_011 ratio65_011 edu_high_01) ///
ciopts(lwidth(*1.5) lcolor(black)) level(90 95) xlabel(-.04 (.02) .04) xscale(range(-.04 (.02) .04)) ///
xline(0) title("DV: Broadband coverage Italy", size(large) pos(11)) aspectratio(1) name(orthogonality_italy, replace)
graph export orthogonality_italy.pdf, name(orthogonality_italy) replace


*
*Table 1: Internet use and party vote in Italy
eststo clear
quietly eststo olssimple:	regress voteM5S internetw4_1 i.centres i.area1, cluster(municip)
quietly eststo olsfull: 	regress voteM5S internetw4_1 $cntrls_it, cluster(municip)
fre votemulti
quietly mlogit votemulti internetw4_1 $cntrls_it, baseoutcome(1) cluster(municip)
eststo vml
foreach o in 6 4 3 5{
quietly margins, dydx(internetw4_1 age10 sex *edu_cat3_rev employed dens011 slope1 unempl_011 ratio65_011 edu_high_01) predict(outcome(`o')) post
eststo, title(Outcome `o')
estimates restore vml
}
eststo drop vml
esttab, b(3) se(3) mtitles nonumbers r2 sfmt(%9.3fc) label star(* 0.1 ** 0.05 *** 0.001) scalars(F) drop(*centres *area1) varwidth(35)


*
*Figure 4: Instrumental variable results all parties
tab vote6_all, gen(vote_party)
*** Reduced form 
eststo clear
eststo voteintrf_p1: regress vote_party1 bband13_01 $cntrls_it, cluster(municip)
eststo voteintrf_p2: regress vote_party2 bband13_01 $cntrls_it, cluster(municip)
eststo voteintrf_p3: regress vote_party3 bband13_01 $cntrls_it, cluster(municip)
eststo voteintrf_p4: regress vote_party4 bband13_01 $cntrls_it, cluster(municip)
eststo voteintrf_p5: regress vote_party5 bband13_01 $cntrls_it, cluster(municip)
eststo voteintrf_p6: regress vote_party6 bband13_01 $cntrls_it, cluster(municip)
* Plot
coefplot ///
(voteintrf_p6, label(M5S)) (voteintrf_p1, label(PD)) (voteintrf_p2, label("Radical Left")) (voteintrf_p3, label("Scelta Civica")) ///
(voteintrf_p4, label(PDL)) (voteintrf_p5, label("Lega Nord")), ///
ciopts(lwidth(*1.5) lcolor(black)) level(90 95) xlabel(-.3 (.1) 0.35) xscale(range(-.3 (.2) 0.35)) ///
keep(bband13_01) ylab("") xline(0) title("Reduced form estimates, all parties, Italy", size(large) position(11)) name(voteintrf_p_it, replace) 
graph export rf_all_parties_italy.pdf, name(voteintrf_p_it) replace
*** 2SLS
eststo clear
eststo voteint2sls_p1: ivregress 2sls vote_party1 $cntrls_it (internetw4_1 = bband13_01), cluster(municip)
eststo voteint2sls_p2: ivregress 2sls vote_party2 $cntrls_it (internetw4_1 = bband13_01), cluster(municip)
eststo voteint2sls_p3: ivregress 2sls vote_party3 $cntrls_it (internetw4_1 = bband13_01), cluster(municip)
eststo voteint2sls_p4: ivregress 2sls vote_party4 $cntrls_it (internetw4_1 = bband13_01), cluster(municip)
eststo voteint2sls_p5: ivregress 2sls vote_party5 $cntrls_it (internetw4_1 = bband13_01), cluster(municip)
eststo voteint2sls_p6: ivregress 2sls vote_party6 $cntrls_it (internetw4_1 = bband13_01), cluster(municip)
* Plot
coefplot ///
(voteint2sls_p6, label(M5S)) (voteint2sls_p1, label(PD)) (voteint2sls_p2, label("Radical Left")) (voteint2sls_p3, label("Scelta Civica")) ///
(voteint2sls_p4, label(PDL)) (voteint2sls_p5, label("Lega Nord")), ///
ciopts(lwidth(*1.5) lcolor(black)) level(90 95) xlabel(-1.2 (.3) 1.5) xscale(range(-1.25 (.3) 1.55)) ///
keep(internetw4_1) ylab("") xline(0) title("TSLS estimates, all parties, Italy", size(large) position(11)) name(voteint2sls_p_it, replace) 
graph export 2sls_all_parties_italy.pdf, name(voteint2sls_p_it) replace


*
*Figure 5: Heterogeneous treatment effects

*Left-right ideology
fre lr4cat
regress voteM5S c.bband13_01##lr4cat $cntrls_it, cluster(municip)
margins, at(lr4cat=(1 2 3 4) bband13_01=(.231 1)) post coefl
eststo itlrcatni: nlcom (_b[5._at]-_b[1bn._at]) (_b[6._at]-_b[2._at]) (_b[7._at]-_b[3._at]) (_b[8._at]-_b[4._at]), post
coefplot ///
itlrcatni, rename(_nl_1 = "Left" _nl_2 = "Center" _nl_3 = "Right" _nl_4 = "None") ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(-.6 (.2) .65) xscale(range(-.6 (.25) .65)) ///
xline(0) title("Left-right scale", size(large) position(11)) ///
name(hetleftright, replace) fysize(55) legend(off) fxsize(50)

* Turnout 2008
fre voted2008
regress voteM5S c.bband13_01##i.voted2008 $cntrls_it, cluster(municip)
margins, at(voted2008=(0 1) bband13_01=(.231 1)) post coefl
eststo hetturnout2008: nlcom (_b[3._at]-_b[1bn._at]) (_b[4._at]-_b[2._at]), post
coefplot ///
hetturnout2008, rename(_nl_1 = "Did not vote" _nl_2 = "Voted 2008"  ) ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(-.2 (.2) .4) xscale(range(-0.2 (0.2) 0.4)) ///
xline(0) title("Turnout 2008", size(large) position(11)) ///
name(hetturnout2008, replace) fysize(45) legend(off) fxsize(50)

* Social class
fre class_cat3
regress voteM5S c.bband13_01##i.class_cat3 $cntrls_it, cluster(municip)
margins, at(class_cat3=(1 2 3) bband13_01=(.231 1))  post coefl
eststo hetclass: nlcom (_b[4._at]-_b[1bn._at]) (_b[5._at]-_b[2._at]) (_b[6._at]-_b[3._at]), post
coefplot ///
hetclass, rename(_nl_1 = "Lower" _nl_2 = "Middle" _nl_3 = "Upper") ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(-.2 (.1) .4) xscale(range(-.2 (.1) .4)) ///
xline(0) title("Social class", size(large) position(11)) ///
name(hetclass, replace) fysize(55) legend(off) fxsize(50)

*Age
fre age_cat3
regress voteM5S c.bband13_01##i.age_cat3 sex i.edu_cat3_rev employed dens011 slope1 i.centres i.area1 unempl_011 ratio65_011 edu_high_01, cluster(municip)
margins, at(age_cat3=(1 2 3) bband13_01=(.231 1))  post coefl
eststo hetage: nlcom (_b[4._at]-_b[1bn._at]) (_b[5._at]-_b[2._at]) (_b[6._at]-_b[3._at]), post
coefplot ///
hetage, rename(_nl_1 = "18-29" _nl_2 = "30-60" _nl_3 = "60+") ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(-.3 (.15) .45) xscale(range(-.3 (.15) .45)) ///
xline(0) title("Age", size(large) position(11)) ///
name(hetage, replace) fysize(55) legend(off) fxsize(50)

graph combine hetleftright hetclass hetturnout2008 hetage, col(2) row(2) /// 
title("Heterogeneous treatment effects (ITT) Italy", size(medium) pos(11)) name(heteffects_italy, replace) 
graph export heteffects_italy.pdf, name(heteffects_italy) replace 



************************************
************************************
*APPENDIX AND ADDITIONAL ANALYSES

//// Residual test

* 1. regress on population density and fixed effects
eststo bbcoverage: regress bband13_01 dens011 slope1 i.centres i.area1, cluster(municip)
* 2. predict residuals
predict bband13_01res, residuals
* 3. check if associated with other variables
eststo residuals: regress bband13_01res unempl_011 ratio65_011 edu_high_01, cluster(municip)
label variable bband13_01res "Residuals"


//// Falsification test

local cntrls_it age10 sex i.edu_cat3_rev employed dens011 slope1 i.centres i.area1 unempl_011 ratio65_011 edu_high_01

*** First stages
regress internetw4_1 bband13_01 `cntrls_it', cluster(municip)
eststo fs_actual: margins, dydx(bband13_01) post
regress newspaperw4_1 bband13_01 `cntrls_it', cluster(municip)
eststo fs_falsify: margins, dydx(bband13_01) post

* Plot
coefplot ///
(fs_actual, label(Internet use)) (fs_falsify, label(Newspaper reading)), ///
ylab("") title("First-stage estimates Italy", size(large) position(11)) xline(0) fxsize(50) ///
legend(pos(6)) ciopts(lwidth(*1.5) lcolor(black)) level(90 95)  name(falsification_test_italy, replace)
graph export falsification_test_italy.pdf, name(falsification_test_italy) replace


//// Relative size of predictors when including left-right scale, and political interest

eststo relsize: regress voteM5S internetw4_1 lrscale01 intpol revtrust_parties `cntrls_it', cluster(municip)

* Plot
coefplot relsize, ///
ciopts(lwidth(*1.5) lcolor(black)) level(90 95) xlabel(-.2 (.1) .4) xscale(range(-.2 (.1) .4)) ///
keep(age10 sex *edu_cat3_rev internetw4_1 lrscale01 intpol revtrust_parties) xline(0) /// 
title("Predictors of populist vote Italy", position(11) size(large)) name(relsize_italy, replace)
graph export predictors_italy.pdf, name(relsize_italy) replace



//// Exploration of heterogeneities
cap drop cons
gen cons = 1
* Ideology (3 categories)
label variable lr3cat "Left-right categories"
local cntrls_it age10 sex i.edu_cat3_rev employed dens011 slope1 i.centres i.area1 unempl_011 ratio65_011 edu_high_01
// Heterogeneity in outcomes due to treatment assingment, i.e. ITT heterogeneity
regress voteM5S c.bband13_01##lr3cat `cntrls_it', cluster(municip)
margins, at(lr3cat=(1 2 3) bband13_01=(.231 1)) post coefl
eststo itlrcatni: nlcom (_b[4._at]-_b[1bn._at]) (_b[5._at]-_b[2._at]) (_b[6._at]-_b[3._at]) , post
test (_nl_1 = _nl_2) (_nl_1 = _nl_3) (_nl_2 = _nl_3), mtest(noadjust)
coefplot ///
itlrcatni, rename(_nl_1 = "Left" _nl_2 = "Center" _nl_3 = "Right" ) ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(-.15 (.15) .45, format(%03.2f) nogrid) xscale(range(-.15 (.15) .45) ) ///
xline(0)  ///
name(hetleftright, replace) fysize(55) legend(off) fxsize(50) title("ITT", size(medsmall) position(11))
// Heterogeneity in terms of first-stage results
regress internetw4_1 c.bband13_01##lr3cat `cntrls_it', cluster(municip)
margins, at(lr3cat=(1 2 3) bband13_01=(.231 1)) post coefl
eststo hetleftrightcompliance: nlcom (_b[4._at]-_b[1bn._at]) (_b[5._at]-_b[2._at]) (_b[6._at]-_b[3._at]) , post
test (_nl_1 = _nl_2) (_nl_1 = _nl_3) (_nl_2 = _nl_3), mtest(noadjust)
coefplot ///
hetleftrightcompliance, rename(_nl_1 = "Left" _nl_2 = "Center" _nl_3 = "Right" ) ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(-.15 (.15) .45, format(%03.2f) nogrid) xscale(range(-.15 (.15) .45) )  ///
xline(0) title("Left-right scale", size(large) position(11)) ///
name(hetleftrightcompliance, replace) fysize(55) legend(off) fxsize(50) title("First stage", size(medsmall) position(11))
// Heterogeity in terms of LATE/ TSLS results
ivregress 2sls voteM5S `cntrls_it' (c.internetw4_1#lr3cat = c.bband13_01#lr3cat) i.cons#lr3cat, cluster(municip) noconst first
margins, at(lr3cat=(1 2 3) internetw4_1=(0 1))  post coefl
eststo hetleftrighttsls: nlcom (_b[2._at]-_b[1bn._at]) (_b[4._at]-_b[3._at]) (_b[6._at]-_b[5._at]) , post
test (_nl_1 = _nl_2) (_nl_1 = _nl_3) (_nl_2 = _nl_3), mtest(noadjust)
coefplot ///
hetleftrighttsls, rename(_nl_1 = "Left" _nl_2 = "Center" _nl_3 = "Right" ) ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(, format(%03.2f) nogrid)   ///
xline(0) title("Left-right scale", size(large) position(11)) ///
name(hetleftrighttsls, replace) fysize(55) legend(off) fxsize(50) title("TSLS", size(medsmall) position(11))

graph combine hetleftright hetleftrightcompliance hetleftrighttsls, col(3) title("Left-right scale", size(medium) position(11)) name(ivplotsleftright, replace)

/*test for no ideology - dummy var: ideology vs no ideology
recode lr4cat (1/3=0 "left-right") (4=1 "no ideo"), gen(lr_noideo)
ivregress 2sls voteM5S $cntrls_it (c.internetw4_1#lr_noideo = c.bband13_01#lr_noideo) i.cons#lr_noideo, cluster(municip) noconst first
margins, at(lr_noideo=(0 1) internetw4_1=(0 1))  post coefl
eststo hetleftrighttsls1: nlcom (_b[2._at]-_b[1bn._at]) (_b[4._at]-_b[3._at]), post
test (_nl_1 = _nl_2), mtest(noadjust)
coefplot ///
hetleftrighttsls1, rename(_nl_1 = "Left-right" _nl_2 = "No ideology" ) ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(, format(%03.2f) nogrid)   ///
xline(0) title("Left-right scale", size(large) position(11)) ///
name(hetleftrighttsls_noideo, replace) fysize(55) legend(off) fxsize(50) title("TSLS", size(medsmall) position(11))
*/

* Age
// Heterogeneity in outcomes due to treatment assingment, i.e. ITT heterogeneity
regress voteM5S c.bband13_01##i.age_cat3 `cntrls_it', cluster(municip)
margins, at(age_cat3=(1 2 3) bband13_01=(.231 1))  post coefl
eststo hetage: nlcom (_b[4._at]-_b[1bn._at]) (_b[5._at]-_b[2._at]) (_b[6._at]-_b[3._at]), post
test (_nl_1 = _nl_2) (_nl_1 = _nl_3) (_nl_2 = _nl_3), mtest(noadjust)
coefplot ///
hetage, rename(_nl_1 = "18-29" _nl_2 = "30-60" _nl_3 = "60+") ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(-.15 (.15) .45, format(%03.2f) nogrid) xscale(range(-.15 (.15) .45)) ///
xline(0) title("Age", size(large) position(11)) ///
name(hetage, replace) fysize(55) legend(off) fxsize(50) title("ITT", size(medsmall) position(11))
// Heterogeneity in terms of first-stage results
regress internetw4_1 c.bband13_01##i.age_cat3 sex i.edu_cat3_rev employed dens011 slope1 i.centres i.area1 unempl_011 ratio65_011 edu_high_01, cluster(municip)
margins, at(age_cat3=(1 2 3) bband13_01=(.231 1))  post coefl
eststo hetagecompliance: nlcom (_b[4._at]-_b[1bn._at]) (_b[5._at]-_b[2._at]) (_b[6._at]-_b[3._at]), post
test (_nl_1 = _nl_2) (_nl_1 = _nl_3) (_nl_2 = _nl_3), mtest(noadjust)
coefplot ///
hetagecompliance, rename(_nl_1 = "18-29" _nl_2 = "30-60" _nl_3 = "60+") ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(, format(%03.2f) nogrid)   ///
xline(0) title("Age", size(large) position(11)) ///
name(hetagecompliance, replace) fysize(55) legend(off) fxsize(50) title("First stage", size(medsmall) position(11))
// Heterogeity in terms of LATE/ TSLS results
ivregress 2sls voteM5S `cntrls_it' (c.internetw4_1#age_cat3 = c.bband13_01#age_cat3) i.cons#age_cat3, cluster(municip) noconst first
margins, at(age_cat3=(1 2 3) internetw4_1=(0 1))  post coefl
eststo hetagetsls: nlcom (_b[2._at]-_b[1bn._at]) (_b[4._at]-_b[3._at]) (_b[6._at]-_b[5._at]), post
test (_nl_1 = _nl_2) (_nl_1 = _nl_3) (_nl_2 = _nl_3), mtest(noadjust)
coefplot ///
hetagetsls, rename(_nl_1 = "18-29" _nl_2 = "30-60" _nl_3 = "60+") ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(, format(%03.2f) nogrid)   ///
xline(0) title("Age", size(large) position(11)) ///
name(hetagetsls, replace) fysize(55) legend(off) fxsize(50) title("TSLS", size(medsmall) position(11))
graph combine hetage hetagecompliance hetagetsls, col(3) title("Age", size(medium) position(11)) name(ivplotsage, replace)

* Social class
local cntrls_it age10 sex i.edu_cat3_rev employed dens011 slope1 i.centres i.area1 unempl_011 ratio65_011 edu_high_01
// Heterogeneity in outcomes due to treatment assingment, i.e. ITT heterogeneity
regress voteM5S c.bband13_01##i.class_cat3 `contrls_it', cluster(municip)
margins, at(class_cat3=(1 2 3) bband13_01=(.231 1))  post coefl
eststo hetclass: nlcom (_b[4._at]-_b[1bn._at]) (_b[5._at]-_b[2._at]) (_b[6._at]-_b[3._at]), post coefl
test (_nl_1 = _nl_2) (_nl_1 = _nl_3) (_nl_2 = _nl_3), mtest(noadjust)
coefplot ///
hetclass, rename(_nl_1 = "Lower" _nl_2 = "Middle" _nl_3 = "Upper") ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(-.2 (.2) .4, format(%03.2f) nogrid) xscale(range(-.2 (.2) .4)) ///
xline(0) title("Social class", size(large) position(11)) ///
name(hetclass, replace) fysize(55) legend(off) fxsize(50) title("ITT", size(medsmall) position(11))
// Heterogeneity in compliance by class
regress internetw4_1 c.bband13_01##i.class_cat3 `contrls_it', cluster(municip)
margins, at(class_cat3=(1 2 3) bband13_01=(.231 1))  post coefl
eststo hetclasscompliance: nlcom (_b[4._at]-_b[1bn._at]) (_b[5._at]-_b[2._at]) (_b[6._at]-_b[3._at]), post
test (_nl_1 = _nl_2) (_nl_1 = _nl_3) (_nl_2 = _nl_3), mtest(noadjust)
coefplot ///
hetclasscompliance, rename(_nl_1 = "Lower" _nl_2 = "Middle" _nl_3 = "Upper") ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(, format(%03.2f) nogrid)   ///
xline(0) title("Social class", size(large) position(11)) ///
name(hetclasscompliance, replace) fysize(55) legend(off) fxsize(50) title("First stage", size(medsmall) position(11))
// Heterogeity in terms of LATE/ TSLS results
ivregress 2sls voteM5S `contrls_it' (c.internetw4_1#class_cat3 = c.bband13_01#class_cat3) i.cons#class_cat3, cluster(municip) noconst first
testparm class_cat3#c.internetw4_1
margins, at(class_cat3=(1 2 3) internetw4_1=(0 1))  post coefl
eststo hetclasstsls: nlcom (_b[2._at]-_b[1bn._at]) (_b[4._at]-_b[3._at]) (_b[6._at]-_b[5._at]), post
test (_nl_1 = _nl_2) (_nl_1 = _nl_3) (_nl_2 = _nl_3), mtest(noadjust)
coefplot ///
hetclasstsls, rename(_nl_1 = "Lower" _nl_2 = "Middle" _nl_3 = "Upper") ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(, format(%03.2f) nogrid)   ///
xline(0) title("Social class", size(large) position(11)) ///
name(hetclasstsls, replace) fysize(55) legend(off) fxsize(50) title("TSLS", size(medsmall) position(11))
graph combine hetclass hetclasscompliance hetclasstsls, col(3) title("Social class", size(medium) position(11)) name(ivplotssocialclass, replace)


* Turnout 2008
local cntrls_it_noage sex i.edu_cat3_rev employed dens011 slope1 i.centres i.area1 unempl_011 ratio65_011 edu_high_01
// Heterogeneity in outcomes due to treatment assingment, i.e. ITT heterogeneity
regress voteM5S c.bband13_01##i.voted2008 `cntrls_it_noage', cluster(municip)
margins, at(voted2008=(0 1) bband13_01=(.231 1)) post coefl
eststo hetturnout2008: nlcom (_b[3._at]-_b[1bn._at]) (_b[4._at]-_b[2._at]), post
test (_nl_1 = _nl_2), mtest(noadjust)
coefplot ///
hetturnout2008, rename(_nl_1 = "Did not vote" _nl_2 = "Voted 2008"  ) ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(-.2 (.2) .4, format(%03.2f) nogrid) xscale(range(-0.2 (0.2) 0.4)) ///
xline(0) title("Turnout 2008", size(large) position(11)) ///
name(hetturnout2008, replace) fysize(45) legend(off) fxsize(50) title("ITT", size(medsmall) position(11))
// Heterogeneity in compliance by voting status
regress internetw4_1 c.bband13_01##i.voted2008 `cntrls_it_noage', cluster(municip)
margins, at(voted2008=(0 1) bband13_01=(.231 1)) post coefl
eststo hetturnout2008compliance: nlcom (_b[3._at]-_b[1bn._at]) (_b[4._at]-_b[2._at]), post
test (_nl_1 = _nl_2), mtest(noadjust)
coefplot ///
hetturnout2008compliance, rename(_nl_1 = "Did not vote" _nl_2 = "Voted 2008"  ) ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(-.5 (.25) .5, format(%03.2f) nogrid) xscale(range(-.5 (.25) .5))   ///
xline(0) title("Turnout 2008", size(large) position(11)) ///
name(hetturnout2008compliance, replace) fysize(45) legend(off) fxsize(50) title("First stage", size(medsmall) position(11))
// Heterogeity in terms of LATE/ TSLS results
ivregress 2sls voteM5S `cntrls_it_noage' (c.internetw4_1#voted2008 = c.bband13_01#voted2008)  i.cons#voted2008, cluster(municip) noconst first
test _b[0b.voted2008#c.internetw4_1] = _b[1.voted2008#c.internetw4_1]
margins, at(voted2008=(0 1) internetw4_1=(0 1))  post coefl
eststo hetturnout2008tsls: nlcom (_b[2._at]-_b[1bn._at]) (_b[4._at]-_b[3._at]), post
test (_nl_1 = _nl_2), mtest(noadjust)
coefplot ///
hetturnout2008tsls, rename(_nl_1 = "Did not vote" _nl_2 = "Voted 2008"  ) ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(, format(%03.1f) nogrid)   ///
xline(0) title("Turnout 2008", size(large) position(11)) ///
name(hetturnout2008tsls, replace) fysize(45) legend(off) fxsize(50) title("TSLS", size(medsmall) position(11))
graph combine hetturnout2008 hetturnout2008compliance hetturnout2008tsls, col(3) title("Turnout 2008", size(medium) position(11)) name(ivplotshetturnout2008, replace)

* Detailed graphs
graph combine ivplotsleftright ivplotssocialclass ivplotshetturnout2008 ivplotsage, row(4) name(hetitaly, replace) title("Italy", position(1))
graph export hetitalydetail3.pdf, replace 
graph display hetitaly, ysize(3.5) xsize(2.5) scale(1) scheme(plotplain) 
graph export hetitalydetail4.pdf,  replace 


* Simple graphs

local cntrls_it_noage sex i.edu_cat3_rev employed dens011 slope1 i.centres i.area1 unempl_011 ratio65_011 edu_high_01
regress voteM5S c.bband13_01##lr4cat `cntrls_it', cluster(municip)
margins, at(lr4cat=(1 2 3 4) bband13_01=(.231 1)) post coefl
eststo itlrcatni: nlcom (_b[5._at]-_b[1bn._at]) (_b[6._at]-_b[2._at]) (_b[7._at]-_b[3._at]) (_b[8._at]-_b[4._at]), post
coefplot ///
itlrcatni, rename(_nl_1 = "Left" _nl_2 = "Center" _nl_3 = "Right" _nl_4 = "None") ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(-.6 (.3) .65, format(%03.2f) nogrid) xscale(range(-.6 (.3) .65)) ///
xline(0) title("Left-right scale", size(large) position(11)) ///
name(hetleftrightd, replace) fysize(55) legend(off) fxsize(50)

coefplot ///
itlrcatni, rename(_nl_1 = "Left" _nl_2 = "Center" _nl_3 = "Right" ) ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(-.15 (.15) .45, format(%03.2f) nogrid) xscale(range(-.15 (.15) .45) ) ///
xline(0)  ///
name(hetleftright, replace) fysize(55) legend(off) fxsize(50) title("Left-right scale", size(medsmall) position(11))

coefplot ///
hetturnout2008, rename(_nl_1 = "Did not vote" _nl_2 = "Voted 2008"  ) ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(-.2 (.2) .4, format(%03.2f) nogrid) xscale(range(-0.2 (0.2) 0.4)) ///
xline(0) title("Turnout 2008", size(large) position(11)) ///
name(hetturnout2008, replace) fysize(45) legend(off) fxsize(50) title("Turnout 2008", size(medsmall) position(11))

coefplot ///
hetclass, rename(_nl_1 = "Lower" _nl_2 = "Middle" _nl_3 = "Upper") ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(-.2 (.2) .4, format(%03.2f) nogrid) xscale(range(-.2 (.2) .4)) ///
xline(0) title("Social class", size(large) position(11)) ///
name(hetclass, replace) fysize(55) legend(off) fxsize(50) title("Social class", size(medsmall) position(11))

coefplot ///
hetage, rename(_nl_1 = "18-29" _nl_2 = "30-60" _nl_3 = "60+") ///
level(90 95) ciopts(lwidth(*1.5) lcolor(black)) xlabel(-.15 (.15) .45, format(%03.2f) nogrid) xscale(range(-.15 (.15) .45)) ///
xline(0) title("Age", size(large) position(11)) ///
name(hetage, replace) fysize(55) legend(off) fxsize(50) title("Age", size(medsmall) position(11))


graph combine hetleftrightd hetclass hetturnout2008 hetage, col(2) row(2) /// 
title("Heterogeneous treatment effects (ITT) Italy", size(medium) pos(11)) name(heteffects_italy_detail, replace) 
graph export heteffects_italy_detail.pdf,  replace 




